package com.yl.ydk.ui.adapter

import android.widget.ImageView
import com.yl.ydk.R
import com.yl.ydk.bean.LiveListBean
import com.yl.ydk.utils.GlideUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

class LiveListAdapter(data: MutableList<LiveListBean.DataX>?) :
    BaseQuickAdapter<LiveListBean.DataX, BaseViewHolder>(
        R.layout.item_live_list,
        data
    ) {

    override fun convert(helper: BaseViewHolder?, item: LiveListBean.DataX?) {
        helper?.let {
           val ivImage  = it.getView<ImageView>(R.id.ivImage)
           val ivHead  = it.getView<ImageView>(R.id.ivHead)
            it.setText(R.id.tvName,item?.title)
            it.setText(R.id.tvDName,item?.user?.name +"  "+ item?.user?.nickname)
            GlideUtils.loadToBackground(mContext,item?.image,ivImage)
            GlideUtils.loadRound(mContext,item?.user?.photo,ivHead)

            it.itemView.setOnClickListener {
                onItemClick?.onListItemClick(item)
            }
        }
    }

    private var onItemClick: onListItemClick? = null

    interface onListItemClick {
        fun onListItemClick(item: LiveListBean.DataX?)
    }

    fun onListItemClick(onListItemClick: onListItemClick?) {
        this.onItemClick = onListItemClick
    }

}